package com.topnav.mc.admin.service.impl;

import com.baomidou.mybatisplus.core.enums.SqlMethod;
import com.topnav.mc.admin.dao.mapper.DevicePositionTempMapper;
import com.topnav.mc.admin.entity.DevicePositionTemp;
import com.topnav.mc.admin.service.IDevicePositionTempService;
import org.springframework.stereotype.Service;
import com.topnav.mc.base.mc.McServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.Date;

@Service
public class DevicePositionTempServiceImpl extends McServiceImpl<DevicePositionTempMapper, DevicePositionTemp,DevicePositionTemp,DevicePositionTemp>
        implements IDevicePositionTempService {

    @Override
    @Transactional
    public boolean save(DevicePositionTemp entity) {
        entity.setTime(new Date());
        if (!super.save(entity)){ return false;}
        return true;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveBatch(Collection<DevicePositionTemp> entityList, int batchSize) {
        for(DevicePositionTemp data : entityList){
            data.setTime(new Date());
        }
        return super.saveBatch(entityList,batchSize);
    }
}
